package com.ruoyi.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archive.domain.SysSimArchive;
import com.ruoyi.archive.service.ISysSimArchiveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * SIM卡档案Controller
 * 
 * @author laifolai
 * @date 2023-02-07
 */
@RestController
@RequestMapping("/archive/manage")
public class SysSimArchiveController extends BaseController
{
    @Autowired
    private ISysSimArchiveService sysSimArchiveService;

    /**
     * 查询SIM卡档案列表
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSimArchive sysSimArchive)
    {
        startPage();
        List<SysSimArchive> list = sysSimArchiveService.selectSysSimArchiveList(sysSimArchive);
        return getDataTable(list);
    }

    /**
     * 导出SIM卡档案列表
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:export')")
    @Log(title = "SIM卡档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSimArchive sysSimArchive)
    {
        List<SysSimArchive> list = sysSimArchiveService.selectSysSimArchiveList(sysSimArchive);
        ExcelUtil<SysSimArchive> util = new ExcelUtil<SysSimArchive>(SysSimArchive.class);
        util.exportExcel(response, list, "SIM卡档案数据");
    }

    /**
     * 获取SIM卡档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:query')")
    @GetMapping(value = "/{cardId}")
    public AjaxResult getInfo(@PathVariable("cardId") Integer cardId)
    {
        return AjaxResult.success(sysSimArchiveService.selectSysSimArchiveByCardId(cardId));
    }

    /**
     * 新增SIM卡档案
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:add')")
    @Log(title = "SIM卡档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSimArchive sysSimArchive)
    {
        return toAjax(sysSimArchiveService.insertSysSimArchive(sysSimArchive));
    }

    /**
     * 修改SIM卡档案
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:edit')")
    @Log(title = "SIM卡档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSimArchive sysSimArchive)
    {
        return toAjax(sysSimArchiveService.updateSysSimArchive(sysSimArchive));
    }

    /**
     * 删除SIM卡档案
     */
    @PreAuthorize("@ss.hasPermi('archive:manage:remove')")
    @Log(title = "SIM卡档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardIds}")
    public AjaxResult remove(@PathVariable Integer[] cardIds)
    {
        return toAjax(sysSimArchiveService.deleteSysSimArchiveByCardIds(cardIds));
    }
}
